<?php

/**
 * News form base class.
 *
 * @method News getObject() Returns the current form's model object
 *
 * @package    symfony
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseNewsForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                   => new sfWidgetFormInputHidden(),
      'title'                => new sfWidgetFormInputText(),
      'text'                 => new sfWidgetFormTextarea(),
      'creation_user_id'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser01'), 'add_empty' => true)),
      'modification_user_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser02'), 'add_empty' => true)),
      'publication'          => new sfWidgetFormChoice(array('choices' => array('published' => 'published', 'notPublished' => 'notPublished', 'published only members' => 'published only members'))),
      'kind'                 => new sfWidgetFormChoice(array('choices' => array('adult' => 'adult', 'young' => 'young'))),
      'category_id'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Category'), 'add_empty' => true)),
      'asset_id'             => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('sfAsset'), 'add_empty' => true)),
      'comment_id'           => new sfWidgetFormInputText(),
      'slug'                 => new sfWidgetFormInputText(),
      'created_at'           => new sfWidgetFormDateTime(),
      'updated_at'           => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                   => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'title'                => new sfValidatorString(array('max_length' => 125)),
      'text'                 => new sfValidatorString(),
      'creation_user_id'     => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser01'), 'required' => false)),
      'modification_user_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser02'), 'required' => false)),
      'publication'          => new sfValidatorChoice(array('choices' => array(0 => 'published', 1 => 'notPublished', 2 => 'published only members'), 'required' => false)),
      'kind'                 => new sfValidatorChoice(array('choices' => array(0 => 'adult', 1 => 'young'), 'required' => false)),
      'category_id'          => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Category'), 'required' => false)),
      'asset_id'             => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('sfAsset'), 'required' => false)),
      'comment_id'           => new sfValidatorInteger(array('required' => false)),
      'slug'                 => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'created_at'           => new sfValidatorDateTime(),
      'updated_at'           => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'News', 'column' => array('slug')))
    );

    $this->widgetSchema->setNameFormat('news[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'News';
  }

}
